home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
swtools
/
trubasic
/
rolldemos
/
demos
/
interact
/
record.tru
< prev
next >
Wrap
Text File
|
1994-08-02
|
2KB
|
100 lines
!
! RECORD version 2.0
!
! Record a series of perspective images of the house.
! Replays them to animate the house spinning.
!
! Note that for X Windows BOX KEEP strings contain ids for pixmaps which
! exist only when the program is running. Therefore we can not write
! the images out to a file, CHAIN to another program, and redisplay them
! using BOX SHOW.
!
LIBRARY "../3d/3dlib.trc"
call tw_wset_title(0,"record")
OPEN #1: screen .25,.7,.25,.7
CALL PersWindow(0,1,0,1,0,1)
DIM image$(1)
LET frames = 30
MAT image$ = Nul$(frames)
FOR i = 1 to frames
CLEAR
LET u = 2*pi*i/frames
LET x = 2*sin(u) + .5
LET y = 2*cos(u) + .5
LET z = 2*sin(u) + .5
CALL SetCamera3(x,y,z)
CALL DrawHouse
ASK WINDOW x1,x2,y1,y2
BOX KEEP x1,x2,y1,y2 in image$(i)
NEXT i
CALL playback(image$,frames)
END
!
! DrawHouse
!
! A slightly complicated 'house' picture, which draws
! an opaque floor. If we're looking at the house from
! above, we must draw the floor first. From below, we
! we must draw the floor last.
!
SUB DrawHouse
DIM house(12,3)
CALL AskCamera3(x,y,z)
IF z>0 then CALL Floor
MAT READ house
PLOT
CALL MatLines3(house)
CALL LineOff3(1,0,.5, 0,0,.5) !parts of roofline
CALL LineOff3(1,1,.5, 0,1,.5)
CALL LineOff3(1,1,0, 0,1, 0)
CALL LineOff3(1,.5,1, 0,.5,1)
DATA 0,0,0, 0,0,.5, 0,.5,1, 0,1,.5, 0,1,0, 0,0,0
DATA 1,0,0, 1,0,.5, 1,.5,1, 1,1,.5, 1,1,0, 1,0,0
CALL RectX3(0,.2,.4,.2,.4) !windows
CALL RectX3(0,.6,.8,.2,.4)
CALL RectY3(0,.45,.55,0,.4) !front door
CALL RectX3(1,.3,.7,.15,.4) !big picture window
CALL CircleY3(1,.3,.4,.1,.4) !weird circular windows
CALL CircleY3(1,.6,.7,.1,.4)
IF z<0 then CALL Floor
END SUB
SUB Floor
SET COLOR "red"
CALL FillRectZ3(0,0,1,0,1)
SET COLOR "yellow"
END SUB
SUB playback(image$(),frames)
!
! Loop displaying frames from array.
!
let i=0
window #0
for n=1 to 100
LET i = i+1
IF i>frames then LET i=1
BOX SHOW image$(i) at .25,.25
PAUSE .04
get mouse x,y,state
if state<>0 then stop
next n
END SUB